package praktikumid.w09.p3;

import java.awt.Canvas;
import java.awt.Color;
import java.awt.Graphics;

public class DrawPanel extends Canvas {
	
	private int ovalX = -1;
	private int ovalY = -1;

	public DrawPanel() {
		setBackground(Color.WHITE);
	}
	
	public void drawOval() {
		ovalX = 100;
		ovalY = 100;
		repaint();
		/*Graphics g = getGraphics();
		g.drawOval(100, 100, 70, 140);
		g.dispose();*/
		System.out.println("drawing oval");
	}
	
	public void drawRectangle() {
		Graphics g = getGraphics();
		g.drawRect(200, 200, 70, 140);
		g.dispose();
		System.out.println("drawing rect");
	}

	public void drawLine() {
		Graphics g = getGraphics();
		g.drawLine(0, 0, 600, 600);
		g.dispose();
		System.out.println("drawing line");
	}
	
	@Override
	public void paint(Graphics g) {
		// TODO Auto-generated method stub
		super.paint(g);
		g.setColor(Color.BLUE);
		g.drawLine(300, 0, 0, 200);
		if (ovalX != -1) {
			g.drawOval(ovalX, ovalY, 70, 140);
		}
	}
}
